/* Given a sequence of integers, { a[i] }, our task is to find the longest
 * 'zig-zag' subsequence { b[j] } such that b[1] > b[2] < b[3] > b[4] .... 
 *
 * To see how to do this, represent adjacent increasing pairs in a[] by '/' 
 * and adjacent decreasing pairs by '\'. This will give us a pattern like the
 * following:
 *
 *     //\/\///\\/\//\/\/
 * 
 * Any zig-zag subsequence must have a subset of the above pattern. In 
 * addition, any consecutive '/' or '\'s will not contribute to extend a
 * zig-zag subsequence, so they can be merged by keeping only the elements
 * at the ends and dropping the elements in between. Finally, any leading '/'s
 * can be ignored.
 */

#include <stdio.h>

int main()
{
    int T, t;
    scanf("%d", &T);
    for (t = 0; t < T; t++)
    {
        int n, i;
        int L = 0;    /* length of longest zig-zag subsequence */
        int tail = 0; /* last element of the current longest subsequence */
        scanf("%d", &n);
        for (i = 0; i < n; i++)
        {
            int x;
            scanf("%d", &x);
            if (L % 2 == 0) /* next element should be big */
            {
                if (L == 0 || x > tail)
                    ++L;
            }
            else            /* next element should be small */
            {
                if (x < tail)
                    ++L;
            }
            tail = x;
        }
        printf("%d\n", L);
    }
    return 0;
}
